Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adjust sendmmsg wrapper to use stack allocated libc types #4190

Merged
merged 6 commits into from
Dec 30, 2024

Conversation

cpubot
Copy link

@cpubot cpubot commented Dec 20, 2024

Problem

The sendmmsg wrapper on linux allocates vectors to initialize headers and their components (iovec, socketaddr_storage) for each packet. See #3569 for more details.

Summary of Changes

This PR stack allocates space in the form of fixed sized arrays for packet headers and their iovec, socketaddr_storage components. Length is capped at libc::UIO_MAXIOV (see https://man7.org/linux/man-pages/man2/sendmmsg.2.html).

This PR also avoids zeroing all uninitialized sockaddr_storage slots and just zeroes mem::size_of::<sockaddr_storage>() - mem::size_of::<sockaddr_in> (or its IPv6 counterpart) for each initialized slot.

Fixes #3569

bw-solana
bw-solana previously approved these changes Dec 20, 2024
Copy link

@bw-solana bw-solana left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - couple small suggestions

streamer/src/sendmmsg.rs Show resolved Hide resolved
streamer/src/sendmmsg.rs Show resolved Hide resolved
bw-solana
bw-solana previously approved these changes Dec 20, 2024
streamer/src/sendmmsg.rs Outdated Show resolved Hide resolved
Copy link

@steviez steviez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Good call on zero'ing out the rest of socketaddr_storage

@cpubot cpubot merged commit 7f2bbd3 into anza-xyz:master Dec 30, 2024
40 checks passed
@cpubot cpubot deleted the sendmmsg-stack branch December 30, 2024 18:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Switch sendmmsg wrapper to use stack allocated libc types
3 participants